package com.web.onirigi.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.web.onirigi.dao.OrderDao;
import com.web.onirigi.model.OrderBean;
import com.web.onirigi.redis.RedisService;
import com.web.onirigi.service.OrderService;
import com.web.onirigi.util.CommontUtil;

@Service
public class OrderServiceImpl implements OrderService {

	@Autowired
	private OrderDao  orderDao;
	
	@Autowired
	private CommontUtil  commontUtil;
	
	
	@Override
	public List<OrderBean> getOrderBeans(OrderBean bean) {
		if(bean.getPageNum() != null) {
			PageHelper.startPage(bean.getPageNum(), bean.getPageSize());
		}
		return orderDao.getOrderBeans(bean);
	}

	@Override
	public String addOrderBean(OrderBean bean) {
		
		/**
		 * 获取订单号
		 */
		Date createDate  =new Date();
		String seqNo =commontUtil.getSeq();
		bean.setOrderId(seqNo);
		bean.setCreateDate(createDate);
		orderDao.addOrderBean(bean);
		
		return seqNo;
	}

	@Override
	public Integer deleteOrderBean(OrderBean bean) {
		return orderDao.deleteOrderBean(bean);
	}

	@Override
	public Integer updateOrderBean(OrderBean bean) {
		return orderDao.updateOrderBean(bean);
	}

}
